package day16.FanSe.FS03;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

public class Text3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {
        method();
        System.out.println("----------");
        Class<?> aClass = Class.forName("day16.FanSe.FS03.Student");
        Field field = aClass.getField("name");
        Student student = (Student) aClass.newInstance();
        field.set(student,"张三");
        System.out.println(student);

    }

    private static Class<?> method() throws ClassNotFoundException, NoSuchFieldException, InstantiationException, IllegalAccessException {
        Class<?> aClass = Class.forName("day16.FanSe.FS03.Student");
        Field field = aClass.getDeclaredField("money");
        field.setAccessible(true);
        Student student = (Student) aClass.newInstance();
        System.out.println(student);
        return aClass;
    }
}
